HAL CORDIC migration: List of applicable concepts

This section provides information about the HAL CORDIC applicable architecture concepts.

Concepts for CORDIC

Concept

Description

Separation of initialization and configuration functions

The initialization has been split into separate initialization and configuration functions:

  • HAL_CORDIC_Init(): initializes the handle and links it to a CORDIC instance.

  • HAL_CORDIC_SetConfig(): sets the basic configuration to enable the use of the CORDIC instance.

Renaming of the handle structure

The handle structure has been renamed to hal_cordic_handle_t.

Renaming unitary init structures

The structure CORDIC_ConfigTypeDef is no longer available and has been replaced by hal_cordic_config_t.

Remove MspInit and MspDeInit callbacks

hal_cordic_MspInit() and hal_cordic_MspDeInit() are no longer available and have been replaced by a user-defined sequence to initialize and configure the CORDIC.

Unitary configuration APIs

New APIs are available to get and set CORDIC features.

Dedicated DMA link APIs replace generic __HAL_LINKDMA macro

The __HAL_LINKDMA macro is no longer provided and new functions HAL_CORDIC_SetWriteDMA() and HAL_CORDIC_SetReadDMA() to link a CORDIC HAL handle to a DMA HAL handle.

Introduction of HAL user data set/get APIs

Two functions to set/get user data are available: HAL_CORDIC_SetUserData() and HAL_CORDIC_GetUserData().

Individual callback registration APIs replace global register and unregister functions

The callback registration is handled by specific functions for each CORDIC event. These functions are used to register callback functions for different CORDIC events.

HAL implementation with LL inline functions

HAL CORDIC APIs now rely on LL APIs rather than performing direct register access.

Define statements and enumerations redirected to LL equivalents

HAL CORDIC define statements and enumerations are based on LL define statements.

Removal of hardware-related macros in HAL2

All hardware macros have been removed from the HAL CORDIC driver, and equivalent services are ensured through the LL APIs.

Revised and optimized HAL state machine

The CORDIC is now managed by five states:

  • HAL_CORDIC_STATE_RESET

  • HAL_CORDIC_STATE_INIT

  • HAL_CORDIC_STATE_IDLE

  • HAL_CORDIC_STATE_ACTIVE

  • HAL_CORDIC_STATE_ABORT

Revised and optimized HAL API status returns

The HAL CORDIC functions were updated to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_ERROR: in case of an error.

  • HAL_TIMEOUT: in case of a user timeout.

  • HAL_BUSY: in case of an ongoing process.

  • HAL_OK: in case of a successfully completed operation.

Revised and optimized HAL error management

Redesign the error handling mechanisms within the HAL to enhance the detection, reporting, and management of errors.

Replaced TypeDef suffix with _t in type names

All TypeDef parts of the HAL CORDIC driver have been removed and replaced by _t.

Replaced nonmodifiable pointers with const keywords

Const keywords have been added to non-modifiable pointers to ensure that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability, prevents unintended modifications, and renders code more robust and maintainable.

Assertion implementation and usage in HAL1

The parameters and state are checked using ASSERT_DBG_STATE and ASSERT_DBG_PARAM macros.

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (including CORDIC instances) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety.

Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).

All HAL CORDIC functions start with HAL_CORDIC.

Remove stm32tnxx_ll_ppp.c files

The stm32tnxx_ll_cordic.c file has been removed.

Other HAL CORDIC changes

Concept

Consideration

Add complementary functions to enable connection of a PERIPHERAL (In and Out) to the CORDIC IP in DMA mode.

Provide the following DMA interface functions: HAL_CORDIC_Write_DMA(), HAL_CORDIC_Write_DMA_opt(), HAL_CORDIC_Read_DMA(), and HAL_CORDIC_Read_DMA_opt() for flexible data transfer with optional interrupt handling.